﻿using Models;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;

namespace Converter
{
    public class CameraToImageConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                if (value is PtCameraInfo)
                {
                    PtCameraInfo camera = value as PtCameraInfo;

                    bool isFeedBackUnhandled = false;

                    if (camera.CAMERA_TYPE == 2) //球机
                    {
                        if (camera.CAMERA_STATE == "1") //在线
                        {
                            if (isFeedBackUnhandled)
                            {
                                return "/Images/qiujiSelected.png";
                            }
                            else
                            {
                                return "/Images/qiuji.png";
                            }
                        }
                        else //离线
                        {
                            return "/Images/qiujiOutline.png";
                        }
                    }
                    else //不是球机
                    {
                        if (camera.CAMERA_STATE == "1")//在线
                        {
                            if (isFeedBackUnhandled)
                            {
                                return "/Images/qiangjiSelected.png";
                            }
                            else
                            {
                                return "/Images/qiangji.png";
                            }
                        }
                        else//离线
                        {
                            return "/Images/qiangjiOutline.png";
                        }
                    }
                }
            }
            catch
            {
                return "/Images/qiuji.png";
            }

            return "/Images/qiuji.png";
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
